# Maintainer: omni <omni+alpine@hack.org>
pkgname=skate
pkgver=1.0.0
pkgrel=0
pkgdesc="A personal key value store"
url="https://github.com/charmbracelet/skate"
arch="all"
license="MIT"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
makedepends="go"
source="https://github.com/charmbracelet/skate/archive/v$pkgver/skate-$pkgver.tar.gz"
options="net" # downloading dependencies

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"

build() {
	mkdir builddir

	go build -v \
		-trimpath \
		-ldflags "-X main.Version=$pkgver -extldflags \"$LDFLAGS\"" \
		-o builddir .

	./builddir/skate man > builddir/skate.1
	./builddir/skate completion bash > completion.bash
	./builddir/skate completion fish > completion.fish
	./builddir/skate completion zsh > completion.zsh
}

check() {
	./builddir/skate --version
}

package() {
	install -Dm755 builddir/skate "$pkgdir"/usr/bin/skate
	install -Dm644 builddir/skate.1 "$pkgdir"/usr/share/man/man1/skate.1
	install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/skate/LICENSE
	install -Dm644 completion.bash "$pkgdir"/usr/share/bash-completion/completions/skate
	install -Dm644 completion.fish "$pkgdir"/usr/share/fish/vendor_completions.d/skate.fish
	install -Dm644 completion.zsh "$pkgdir"/usr/share/zsh/site-functions/_skate
}

sha512sums="
0164ff45e965cba3c4fbf40345d0ca39680bee2baffdb0b40db7e9ae445cb6c4f2864a0e6732f22fd22081d50101a2ef5d7891351a89195a104518476f455970  skate-1.0.0.tar.gz
"
